package com.software.creatot;

import java.util.ArrayList;
import java.util.List;

public class Meal {

    private List<Item> itemList = new ArrayList<>();

    //点餐
    public void addItem(Item item) {
        itemList.add(item);
    }

    //付钱
    public float getCost() {
        float total = 0.0f;
        for (Item item : itemList) {
            total += item.price();
        }
        return total;

    }

    StringBuilder sb = new StringBuilder();

    //查看订单
    public void showItem() {
        for (Item item : itemList) {
            sb.append(item.name())
                    .append("用")
                    .append(item.packing().pack())
                    .append("价格是")
                    .append(item.price())
                    .append(">>>");
            System.out.println(sb.toString());
        }

    }

}
